﻿<UserControl x:Class="Notoric.View.Music.CWNotation.Controls.Arc"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:cvr="clr-namespace:Notoric.View.Music.CWNotation.Converters"
             Cursor="Hand" MouseLeftButtonDown="UserControl_MouseLeftButtonDown">
    <UserControl.Resources>
        <Style TargetType="{x:Type Thumb}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Thumb}">
                        <Grid x:Name="PART_Content" Visibility="Collapsed">
                            <Ellipse Height="6" Width="6" Margin="-3 -3 0 0">
                                <Ellipse.Fill>
                                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                        <GradientBrush.GradientStops>
                                            <GradientStopCollection>
                                                <GradientStop Color="#CCC" Offset="0.0"/>
                                                <GradientStop Color="#AAA" Offset="1.0"/>
                                            </GradientStopCollection>
                                        </GradientBrush.GradientStops>
                                    </LinearGradientBrush>
                                </Ellipse.Fill>
                            </Ellipse>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=FixedPage}}" Value="{x:Null}">
                                <Setter TargetName="PART_Content" Property="Visibility" Value="Visible"/>
                            </DataTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <cvr:VisibilityConverter x:Key="VisibilityConverter"/>
    </UserControl.Resources>
    <Canvas>
        <Path Stroke="Black" StrokeThickness="0.02cm">
            <Path.Data>
                <PathGeometry>
                    <PathGeometry.Figures>
                        <PathFigure StartPoint="{Binding StartingPoint, Mode=OneWay}">
                            <BezierSegment Point1="{Binding BezierPoint1, Mode=OneWay}" Point2="{Binding BezierPoint2, Mode=OneWay}" Point3="{Binding EndingPoint, Mode=OneWay}" />
                        </PathFigure>
                    </PathGeometry.Figures>
                </PathGeometry>
            </Path.Data>
        </Path>
        <Thumb x:Name="PART_StartPointThumb" Canvas.Left="{Binding StartingPoint.X, Mode=OneWay}" Canvas.Top="{Binding StartingPoint.Y, Mode=OneWay}" Cursor="Hand"
               DragDelta="PART_StartPointThumb_DragDelta" DragCompleted="PART_StartPointThumb_DragCompleted" Visibility="{Binding IsSelected, Mode=OneWay, Converter={StaticResource VisibilityConverter}}"/>
        <Thumb x:Name="PART_EndPointThumb" Canvas.Left="{Binding EndingPoint.X, Mode=OneWay}" Canvas.Top="{Binding EndingPoint.Y, Mode=OneWay}" Cursor="Hand"
               DragDelta="PART_EndPointThumb_DragDelta" DragCompleted="PART_EndPointThumb_DragCompleted" Visibility="{Binding IsSelected, Mode=OneWay, Converter={StaticResource VisibilityConverter}}"/>
        <Thumb x:Name="PART_Bezier1Thumb" Canvas.Left="{Binding BezierPoint1.X, Mode=OneWay}" Canvas.Top="{Binding BezierPoint1.Y, Mode=OneWay}" Cursor="Hand"
               DragDelta="PART_Bezier1Thumb_DragDelta" DragCompleted="PART_Bezier1Thumb_DragCompleted" Visibility="{Binding IsSelected, Mode=OneWay, Converter={StaticResource VisibilityConverter}}"/>
        <Thumb x:Name="PART_Bezier2Thumb" Canvas.Left="{Binding BezierPoint2.X, Mode=OneWay}" Canvas.Top="{Binding BezierPoint2.Y, Mode=OneWay}" Cursor="Hand"
               DragDelta="PART_Bezier2Thumb_DragDelta" DragCompleted="PART_Bezier2Thumb_DragCompleted" Visibility="{Binding IsSelected, Mode=OneWay, Converter={StaticResource VisibilityConverter}}"/>
    </Canvas>
</UserControl>
